<?php

class Third_EntityFile{
	private $entity;
	private $entity_data;
	private $path = xml_FORM_PATH;
	
	function __construct( $entity, $entity_data ){
		$this->file 	= new Files();
		$this->file->backup = true;
		$this->setEntity( $entity );
		$this->setEntityData( $entity_data );
	}

	public function setEntity( $entity ){
		$this->entity = $entity;
	}
	
	public function getEntity(){
		return $this->entity;
	}
	
	public function setEntityData( $entity_data ){
		$this->entity_data = $entity_data;
	}
	
	public function getEntityData(){
		return $this->entity_data;
	}
	
	public function create_class(){
		$class = CLASS_PATH.$this->entity_data->class.'.php';
				
		$this->file->content = 	str_replace('<!-- Entity -->', 
								$this->entity_data->class, 
								$this->file->getContent( ENTITY_CLASS )
							);
							
		$this->file->backup  = true;
		$this->file->saveTo( $class );
	}
	
	public function create_entity_xml( $mode = "data_base" ){
		
		$this->file->content 	= $this->entity_data->getEntityXML( $mode );
		$this->file->backup 	= true;

		$this->file->saveTo( $this->entity->file );
	}
	
	public function saveEntity( $org, $dest ){
		
		$this->file->content 	= file_get_contents( $org );
		$this->file->backup 	= true;
		
		$this->file->saveTo( $dest );
	}
}

?>